package errorType

type ErrCode struct {
	Code    int
	Message string
}

func (e ErrCode) Error() string {
	return e.Message
}

func DecodeErr(err error) (int, string) {
	if err == nil {
		return OK.Code, OK.Message
	}
	switch typed := err.(type) {
	case *ErrCode:
		return typed.Code, typed.Message
	default:
		return InternalServerError.Code, InternalServerError.Message
	}
}
